function shell_report_rate_adjustment(scale_vec, ...
        ssolve_market_all, nnon_converge_all, ssolve_market, nnon_converge,...
        D, K, N, D_enroll_st, pr_y, alpha, B1_c, beta_c, T1, B2_c,...
        ssolve_market_all2, nnon_converge_all2, ssolve_market2, nnon_converge2,...
        lr_target, export_tex, folder_tex_cf, OO, OO2, resource_y1, T2)
%% identify markets where convergence reached 
nnon_converge_all3 = nnon_converge_all + nnon_converge_all2;
nnon_converge3 = nnon_converge + nnon_converge2;

ss_ind = find(scale_vec==1);
p1_eq            = OO(ss_ind).p1_cf; % N.ist x 1
p2_eq            = OO(ss_ind).p2_cf; % N.ist x KM
n_eq             = OO(ss_ind).n_cf;  %N.st x 1
profit_eq        = OO(ss_ind).profit_cf; % N.ist x 1
non_converge_all = OO(ss_ind).non_converge_all_cf; % N.ist x 1
solve_market_all = OO(ss_ind).solve_market_all_cf; % N.ist x 1
fsolve_all       = OO(ss_ind).fsolve_all_cf; % N.ist x 1
EV_y             = OO(ss_ind).EV_y_cf; % N.st x N_y
enrollment_eq    = OO(ss_ind).enrollment_cf; % N.st x 1
enrollment_m_eq  = OO(ss_ind).enrollment_m_cf; % N.st x 1
enrollment_f_eq  = OO(ss_ind).enrollment_f_cf; % N.st x 1
non_converge     = OO(ss_ind).non_converge_cf; % N.st x 1
solve_market     = OO(ss_ind).solve_market_cf; % N.st x 1
rs_share_eq      = OO(ss_ind).rs_share_cf;  % N.ist x 1

[fit_off_st, fit_off_ist] = report_baseline(enrollment_eq, non_converge, solve_market,...
    D, K, N, D_enroll_st);

%% changes relative to respective baseline cost equilibrium
ss_ind = find(scale_vec==1);
ns = length(scale_vec);

disp(' ')
disp('====================================================')
disp('Baseline Medicaid')

RS = report_outcome(OO, ns, ss_ind, ...
    ssolve_market_all, nnon_converge_all3, ssolve_market, nnon_converge3,...
    D, K, N, D_enroll_st, pr_y, alpha, B1_c, beta_c, T1, B2_c,...
    fit_off_st, fit_off_ist, resource_y1, T2);

disp(' ')
disp('====================================================')
disp('Generous Medicaid')

RS2 = report_outcome(OO2, ns, ss_ind, ...
    ssolve_market_all, nnon_converge_all3, ssolve_market, nnon_converge3,...
    D, K, N, D_enroll_st, pr_y, alpha, B1_c, beta_c, T1, B2_c,...
    fit_off_st, fit_off_ist, resource_y1, T2);

%% generate Figure 6 and Figure 7
% baseline Medicaid
xl = '$c^1_{jk}$ multiplier'; % x-axis label
fig_title = 'Counterfactual rate stability regulation';
lr = 0;
if export_tex==1
    export_result(RS, scale_vec, xl, fig_title, lr, lr_target, folder_tex_cf);
end

% baseline & generous Medicaid together
xl = '$c^1_{jk}$ multiplier'; % x-axis label
fig_title = 'Baseline Medicaid vs. Generous Medicaid';
lr = 0;
if export_tex==1
    export_result2(RS2, RS, scale_vec, xl, fig_title, lr, lr_target, folder_tex_cf);
end

%% generate Table 4
% baseline Medicaid vs. Generous Medicaid (baseline cost estimates, i.e., scale=1)
ss_ind = find(scale_vec==1);

p1_eq            = OO(ss_ind).p1_cf;
p2_eq            = OO(ss_ind).p2_cf;
n_eq             = OO(ss_ind).n_cf;
profit_eq        = OO(ss_ind).profit_cf;
EV_y             = OO(ss_ind).EV_y_cf;
enrollment_eq    = OO(ss_ind).enrollment_cf;

p1_eq2            = OO2(ss_ind).p1_cf;
p2_eq2            = OO2(ss_ind).p2_cf;
n_eq2             = OO2(ss_ind).n_cf;
profit_eq2        = OO2(ss_ind).profit_cf;
EV_y2             = OO2(ss_ind).EV_y_cf;
enrollment_eq2    = OO2(ss_ind).enrollment_cf;

ind_N = find(ssolve_market_all==1 & nnon_converge_all3==0 & fit_off_ist==0);
ind_major = find(ssolve_market_all==1 & nnon_converge_all3==0 & fit_off_ist==0 & D.major==1);
ind_minor = find(ssolve_market_all==1 & nnon_converge_all3==0 & fit_off_ist==0 & D.major==0);
ind_M = find(ssolve_market==1 & nnon_converge3==0 & fit_off_st==0);

ind_minor_flag  = find(ssolve_market==1 & nnon_converge3==0  & n_eq<1);
ind_minor_flag2 = find(ssolve_market==1 & nnon_converge3==0  & n_eq2<1);

% baseline: compute the mean outcomes
lq=0.01;
uq=0.99;

m_p1_eq = mean(p1_eq(ind_N));
m_p1_eq2 = mean(p1_eq2(ind_N));
p1_change = 100*(p1_eq2-p1_eq)./p1_eq;
p1_change = cndtl_mean(p1_change, ind_N, lq, uq);

m_p2_eq = sum(p2_eq.*D.pr_s_m,2); % N.ist x 1
m_p2_eq = mean(m_p2_eq(ind_N));

m_p2_eq2 = sum(p2_eq2.*D.pr_s_m,2); % N.ist x 1
m_p2_eq2 = mean(m_p2_eq2(ind_N));

p2_change = 100*(p2_eq2-p2_eq)./p2_eq;
Ep2_change = sum(p2_change.*D.pr_s_m,2);
Ep2_change = cndtl_mean(Ep2_change, ind_N, lq, uq);

m_n_eq = mean(n_eq(ind_M));
m_n_eq2 = mean(n_eq2(ind_M));
n_change = 100*(n_eq2-n_eq)./n_eq; % N.st x 1
n_change = cndtl_mean(n_change, ind_M, lq, uq);

m_profit = mean(profit_eq(ind_major));
m_profit2 = mean(profit_eq2(ind_major));

f_profit = mean(profit_eq(ind_minor));
f_profit2 = mean(profit_eq2(ind_minor));

profit_change = 100*(profit_eq2-profit_eq)./profit_eq; % N.ist x 1;
profit_change_major = cndtl_mean(profit_change, ind_major, lq, uq);
profit_change_minor = cndtl_mean(profit_change, ind_minor, lq, uq);

m_enroll = mean(enrollment_eq(ind_M));
m_enroll2 = mean(enrollment_eq2(ind_M));
enrollment_change = 100*(enrollment_eq2-enrollment_eq)./enrollment_eq; % N.st x 1
enrollment_change = cndtl_mean(enrollment_change, ind_M, lq, uq);

EV_change = exp((EV_y2-EV_y)/(alpha*(B1_c+beta_c^T1*B2_c))); % N.st x N_y, 1+delta
EV_change = 100*(EV_change-1); % 100*delta, express the change in % terms
EV_change_all = EV_change*pr_y; % N.st x 1
EV_change_all = mean(EV_change_all(ind_M));

% export
file_tex = fullfile(folder_tex_cf, 'table_medi_eq.tex');
FID = fopen(file_tex, 'w');
fprintf(FID, '\\begin{table} \n');
fprintf(FID, '\\begin{center} \n');
fprintf(FID, '\\scalebox{1.0}{ \n');
fprintf(FID, '\\begin{tabular}{lcc} \\hline \n');
fprintf(FID, '                              & \\%% change from baseline economy \\\\ \n');
fprintf(FID, '\\hline \n');
fprintf(FID, 'Initial rate  & %10.2f \\\\ \n', ...
    p1_change);
fprintf(FID, 'Revised rate  & %10.2f \\\\ \n', ...
    Ep2_change);
fprintf(FID, 'Fringe entrants & %10.2f \\\\ \n', ...
    n_change);
fprintf(FID, 'Major insurer profits   & %10.2f \\\\ \n', ...
    profit_change_major);
fprintf(FID, 'Fringe insurer profits  & %10.2f \\\\ \n', ...
    profit_change_minor);
fprintf(FID, 'Private LTCI coverage rate & %10.2f \\\\ \n', ...
    enrollment_change);
fprintf(FID, '\\hline \n');
fprintf(FID, '\\end{tabular} \n');
fprintf(FID, '} \n');
fprintf(FID, '\\end{center} \n');
fprintf(FID, '\\caption{Medicaid generosity and market outcomes \\newline \\small {\\emph{Notes}: The table reports percent changes in outcomes as the economy moves from the baseline regime to a counterfactual regime with more generous Medicaid benefits.}} \n');
fprintf(FID, '\\label{table_medi_eq} \n');
fprintf(FID, '\\end{table} \n');


















